import { EffectService } from './effect.service';
import { Component, OnInit } from '@angular/core';
import { City} from "./city";
import { SelectItem } from 'primeng/api';
import { EffectFA } from './effect-fa';
declare function init(map): void;
@Component({
  selector: 'effect',
  templateUrl: './effect.component.html',
  styleUrls: ['./effect.component.scss']
})

export class EffectComponent implements OnInit {

  cities: City[] = [
    {adNm: 'New York', adCd: 'NY'},
    {adNm: 'Rome', adCd: 'RM'},
    {adNm: 'London', adCd: 'LDN'},
    {adNm: 'Istanbul', adCd: 'IST'},
    {adNm: 'Paris', adCd: 'PRS'}
  ];

  selectedCity: City;
  projNm;
  types: SelectItem[];
  falist:EffectFA[];
  timeval: string='1';
  val: number;
  constructor(private effectService:EffectService) {
    this.types =  [
      {label: '近一年', value: '1'},
      {label: '近十年', value: '10'},
      {label: '近二十年', value: '20'}
    ];
  }

  ngOnInit() {
    this.getFAList("0");
    init('mapDiv');
  }
  loadslide(){
    
  }
  handleChange(e, op) {
    op.show(e);
    this.val = e.value;
  }
  getFAList(dataType:string): void{
    this.effectService.getFAList(dataType).subscribe(list => this.falist=list);
  }
  setStyles() {
    let styles;
    styles = {
      'right': 73+(95-this.val)*4.5+'px'
    };
    return styles;
  }
  sjdClick($event):void{
    if($event.value=='1'){
      this.getFAList("0");
    }
    else if($event.value=='10'){
      this.getFAList("1");
    }
    else{
      this.getFAList("2");
    }
  }
}
